package hk.com.ocsl
{
	import flash.external.ExternalInterface;
	import flash.system.Capabilities;
	
	public class SystemHelper
	{
		protected static var _version:Array = [];
		protected static var _platform:String;
		public function SystemHelper()
		{
		}
		
		protected static function setUp():void
		{
			var v:String = flash.system.Capabilities.version;
				var buffer:String = new String();
				for(var i:uint =0; i<v.length; i++)
				{
					if(v.charAt(i) == " ")
					{
						_platform = buffer;
						buffer = "";
					}
					else if(v.charAt(i) == ",")
					{
						_version.push(buffer);
						buffer = "";
					}
					else
						buffer += v.charAt(i);
				}
		}
		public static function GetMajorVersion():uint
		{
			if(_version.length === 0)
			{
				setUp();
			}
			
			ExternalInterface.call( 'console.log', "major version: "+_version[0]);
			 return uint("0x"+_version[0]);
			
		}
		public static function GetMinorVersion():uint
		{
			if(_version.length === 0)
			{
				setUp();
			}
			 return uint(_version[1]);
		}
		public static function GetBuildNumber():uint
		{
			if(_version.length === 0)
			{
				setUp();
			}
			 return uint(_version[2]);
		}
		public static function GetInternalBuildNumber():uint
		{
			if(_version.length === 0)
			{
				setUp();
			}
			 return uint(_version[3]);
		}
		public static function GetPlatform():String
		{
			if(!_platform)
			{
				setUp();
			}
			 return _platform;
		}
		
	}
}